package Lee_code;

import java.util.HashSet;

public class Lee_202 {
    public boolean isHappy(int n) {
        HashSet<Integer> set = new HashSet<Integer>();
        int sum = 0;
        while(sum!=1&&!set.contains(sum))
        {
            sum = get_next(n);
            set.add(sum);
        }

        return sum==1;
    }
    public  static int get_next(int num)
    {
        int sum = 0;
        while(num>0)
        {
            int temp = num%10;
            num = num/10;
            sum = sum + temp*temp;
        }
        return sum;
    }
    public static void main(String[] args) {



    }
}
